package com.ghsc.ghxc.jsb.view

import android.content.Context
import android.widget.TextView
import com.cn.appcore.ext.setOnFastClickListener
import com.ghsc.ghxc.jsb.R
import com.lxj.xpopup.core.CenterPopupView

class CenterSelectPopup(
    context: Context,
    title: String = "温馨提示",
    message: String = "",
    leftText: String = "取消",
    rightText: String = "确定",
    sure: () -> Unit,
    cancel: () -> Unit={},
) : CenterPopupView(context) {

    private val mContext = context
    private val title = title
    private val message = message
    private val leftText = leftText
    private val rightText = rightText
    private var sure: () -> Unit = sure
    private var cancel: () -> Unit = cancel

    override fun getImplLayoutId() = R.layout.layout_popup_center_select

    override fun onCreate() {
        super.onCreate()
        val tvCancel = findViewById<TextView>(R.id.tvCancel)
        val tvSure = findViewById<TextView>(R.id.tvSure)
        val tvMessage = findViewById<TextView>(R.id.tvMessage)
        val tvTitle = findViewById<TextView>(R.id.tvTitle)
        tvTitle.text = title
        tvMessage.text = message
        tvCancel.text = leftText
        tvSure.text = rightText
        tvCancel.setOnFastClickListener {
            cancel.invoke()
            dismiss()
        }
        tvSure.setOnFastClickListener {
            sure.invoke()
            dismiss()
        }
    }

    override fun getMaxWidth() = 0
}